package com.qf.order.controller;

import com.qf.order.entity.Order;
import com.qf.order.entity.Producted;
import com.qf.order.service.OrderService;
import com.qf.order.service.ProductedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping
public class OrderContreoller {

    @Autowired
    OrderService orderService;
    @Autowired
    ProductedService productedService;


    @RequestMapping("/bar")
    public Map<String,List<String>> bar(){
        //     categories: ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"],
        //     values: [5, 20, 36, 10, 10, 20]
        ArrayList<String> strings = new ArrayList<>();


        //调用product查询数据返回页面---》查询 表中 商品名
        List<Order> list = orderService.list();
        for (Order order : list) {
            String s = order.getSalesVolume().toString();
            strings.add(s);
        }

        ArrayList<String> strings1 = new ArrayList<>();

        List<Producted> list1 = productedService.list();
        for (Producted producted : list1) {
            String s = producted.getProductName().toString();
            strings1.add(s);
        }

        HashMap<String, List<String>> map = new HashMap<>();
        map.put("values",strings);
        map.put("categories",strings1);

        return map;


    }

}
